from sqlalchemy import Column, Integer, DateTime, Enum, ForeignKey
from sqlalchemy.orm import relationship
from config.database import Base

class BaInOutRecord(Base):
    """
    进退分记录表
    """

    __tablename__ = 'ba_in_out_records'

    id = Column(Integer, primary_key=True, autoincrement=True, comment='ID')
    m_id = Column(Integer, ForeignKey('ba_machine.id'), nullable=True, default=None, comment='机器id')
    Type = Column(Enum("0", "1", "2", "3", name='Type_enum'), nullable=True, default=None, comment='0= 进分 1=退分 2=开分 3=洗分')
    Num = Column(Integer, nullable=True, default=None, comment='分数')
    Time = Column(DateTime, nullable=True, default=None, comment='客户端传的时间')
    create_time = Column(Integer, nullable=True, default=None, comment='创建时间')

    machine = relationship("BaMachine", 
                        back_populates="inout_records",
                        foreign_keys=[m_id])